/**
 * Created by wangshaohua on 2018/1/25.
 */
moduleContent.controller("ContentFolderMgt", function (UploadFileService, $$CambioConfig, ExerciseContentResource, $scope, $log, $state, $stateParams, GeneralResource, LoadingService, ConstantService, DialogService) {
    initPage($scope);
    $scope.$on("ngDialog.opened", function () {
        dialogOnLoad();
    });

    // ------------------------------------------------------------------------------------------------------

    $scope.cancel = function () {
        DialogService.close();
    };

    $scope.submit = function () {
        $scope.currentFolder.recordType = Enums.ExerciseContentRecordTypeEnum.FOLDER;
        Alert.confirm(function () {
            if ($scope.currentFolder.id) {
                ExerciseContentResource.updateFolder({}, $scope.currentFolder, function (result) {
                    // $scope.$parent.parentId = result.data.value;
                    Alert.success();
                    DialogService.close();
                });
            } else {
                ExerciseContentResource.saveFolder({}, $scope.currentFolder, function (result) {
                    // $scope.$parent.currentParentId = result.data.value;
                    Alert.success();
                    DialogService.close();
                });
            }
        })
    }
    // ------------------------------------------------------------------------------------------------------
    // ------------------------------------------------------------------------------------------------------
});